<template>
  <div class="index_item">
    <div class="index_item_top">
      <keep-alive>
        <router-view></router-view>
      </keep-alive>
    </div>
    <div class="index_item_bom">
      <tabMenu></tabMenu>
    </div>
  </div>
</template>

<script>
import login from "@/network/login/login.js";
import tabMenu from "@/components/tab/tabMenu.vue";
export default {
  name: "home",
  components: {
    tabMenu,
  },
  data() {
    return {};
  },
  methods: {},
  created() {
    this.$store.commit("addUser",{user:JSON.parse(localStorage.getItem('userInfo')),token:localStorage.getItem('token')})
  },
  async beforeRouteEnter(to, from, next) {
    if(JSON.parse(localStorage.getItem('userInfo'))){
      let userInfo= JSON.parse(localStorage.getItem('userInfo'));
        const {data:res}=await login({account:userInfo.username,pwd:userInfo.pwd});
        if(res.message!="success") return  next({ path: '/login' }) ;
         next() ;
    }
    else{
         next({ name: 'Login' }) ;
    }
  }
};
</script>
<style scoped lang="less">
@import "../assets/css/index.less";
.index_item {
  height: 203vw;
  border-color: #ffffff;
}
</style>